unit uMensagem;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, FMTBcd, StdCtrls, Buttons, DB, DBClient, Provider, SqlExpr,
  Mask, DBCtrls, DBXpress;
type
  TForm1 = class(TForm)
    lbl1: TLabel;
    SQLDataSet1: TSQLDataSet;
    DataSetProvider1: TDataSetProvider;
    ds1: TClientDataSet;
    ds2: TDataSource;
    ds1PARAMETRO: TStringField;
    ds1DESCRICAO: TStringField;
    SQLDataSet1PARAMETRO: TStringField;
    SQLDataSet1DESCRICAO: TStringField;
    OK: TBitBtn;
    Sair: TBitBtn;
    edt1: TEdit;
    procedure FormShow(Sender: TObject);
    procedure OKClick(Sender: TObject);
    procedure SairClick(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

uses UDM;

{$R *.dfm}

procedure TForm1.FormShow(Sender: TObject);
begin
   if (ds1.Active) then
     ds1.Close;
   ds1.Params[0].AsString := 'MENSAGEM';
   ds1.Open;
   if (not ds1.IsEmpty)then
   begin
     edt1.Text := ds1DESCRICAO.AsString;
   end;
   ds1.Close;
end;

procedure TForm1.OKClick(Sender: TObject);
var
  sqltexto : string;
  TD: TTransactionDesc;
begin
    TD.TransactionID := 1;
    TD.IsolationLevel := xilREADCOMMITTED;
    dm.scSge.StartTransaction(TD);
    sqltexto := 'UPDATE PARAMETRO SET DESCRICAO = ' + QuotedStr(edt1.Text);
    sqltexto := sqltexto + ' WHERE PARAMETRO = ' +  QuotedStr('MENSAGEM');
    dm.scSge.ExecuteDirect(sqltexto);
    dm.scSge.Commit(TD);
end;

procedure TForm1.SairClick(Sender: TObject);
begin
  close;
end;

end.
